import axios from "axios";
import { ElMessage } from "element-plus";
import { useCounterStore } from "../stores";
const store=useCounterStore

const service = axios.create({
    baseURL:'/system',
})

service.interceptors.request.use(request=>{
	request.headers.Authorization=sessionStorage.getItem('token');
	return request
}
)

// 添加响应拦截器
service.interceptors.response.use(response=>{
	console.log(response)
	if(response.status!==200){
		ElMessage({
			showClose: true,
			message: '请求异常 X.x',
			type: 'error',
		})
		return Promise.reject(response)
	}
	const res=response.data
	if(res.data!==0){
		return Promise.resolve(res)
	}
	return res
}
)
export default service